Array와 Tuple중 Array가 먼저 infer되므로 as const
활용 해야함
keyof
는 intersection처럼 작동한다.
interface AMap {
'AAA': never;
}
interface BMap {
'B': never;
'BB': never;
'BBB': string;
}
interface CMap {
'C': number;
'CC': string;
'CCC': Function;
'CCCC': Map<any, any>;
}
export type ABCEventMap = AMap & BMap & CMap;
export type ABCType = keyof ABCMap; // keyof AMap | keyof BMap | keyof CMap
제너릭에 타입 파라미터 사용시 추론이 안되는 문제
Argument of Type 'InterfaceDerived' is not assinable to parameter of type 'interfaceBase'
https://stackoverflow.com/questions/51808160/keyof-inferring-string-number-when-key-is-only-a-string
interface XMap {
[key: string]: any;
}
type X = keyof XMap; // number | string